package example.json

import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule

/**
 *
 * @author tzp
 * @since 2022/8/16
 */
object JacksonTest {
  case class Dog(name: String, age: Int)

  def main(args: Array[String]): Unit = {
    val mapper = JsonMapper.builder()
      .addModule(DefaultScalaModule)
      .build()

    val aDog = Dog("a", 1)
    println(mapper.writeValueAsString(aDog))

    val aDogStr = mapper.writeValueAsString(aDog)
    val aDogDer = mapper.readValue[Dog](aDogStr, classOf[Dog])
    println(aDogDer)
  }
}
